package com.jianbo.proxy.util;

import com.jianbo.proxy.conf.ArgsConf;

public class PathUtil {
    public static String truePath(String path) {
        // 从前端目录中读取 @/ 开头
        if(path.startsWith("@/")) {
            ArgsConf argsConf = ArgsConf.getInstance();
            path = path.replace("@/", argsConf.getFrontDir());
        } else if(path.startsWith("#/")) {
            // 从配置目录中读取 #/ 开头
            ArgsConf argsConf = ArgsConf.getInstance();
            path = path.replace("#/", argsConf.getConfDir());
        } 
        return path;
    }

    public static String clearEnd(String cachePath) {
        if(cachePath.endsWith("/")) {
            return cachePath.substring(0, cachePath.length() - 1);
        }
        return cachePath;
    }
}
